export class RemoveWidgetCommand {
  constructor(widget, widgetList, selectWidget, widgetMap) {
    this.widget = widget
    this.widgetList = widgetList
    this.selectWidget = selectWidget
    this.targetIdx = -1
    this.widgetMap = widgetMap
  }
  execute() {
    this.targetIdx = this.widgetList.findIndex((item) => item.options.propName == this.widget.options.propName)
    this.widgetList.splice(this.targetIdx, 1)
    this.selectWidget(null)
    this.widgetMap.delete(this.widget.options.propName)
  }
  undo() {
    this.widgetList.splice(this.targetIdx, 0, this.widget)
    this.selectWidget(this.widget)
    this.widgetMap.set(this.widget.options.propName, this.widget)
  }
}
